using System.Windows.Controls;

namespace FrontDisplay
{
    internal class MoveRightAnimation : IAnimation
    {
        public void Initialize(Control control)
        {
            control.SetValue(Canvas.LeftProperty, -control.Width);
        }

        public bool NextStep(Control oldControl, Control newControl)
        {
            double left = (double)newControl.GetValue(Canvas.LeftProperty);

            left += newControl.Width * Animation.AnimationStep;
            if (left >= 0)
            {
                left = 0;
            }

            oldControl.SetValue(Canvas.LeftProperty, left + newControl.Width);
            newControl.SetValue(Canvas.LeftProperty, left);

            return (left < 0);
        }
    }
}